package com.wuge.auth.controller;

import com.alibaba.fastjson.TypeReference;

import com.wuge.auth.feign.MemberFeign;
import com.wuge.common.to.MemberTo;
import com.wuge.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class OAuthIndexController {
    @Autowired
    private MemberFeign memberFeign;
@RequestMapping("/OauthLogin")
    public String GiteeLogin(String code, HttpSession httpSession){
    R giteelogin = memberFeign.Giteelogin(code);

    MemberTo memberTo = giteelogin.getData(new TypeReference<MemberTo>() {

    });
    httpSession.setAttribute("loginUser",memberTo);
    return "redirect:http://gulimall.com";
}
}
